package lesson3.slides.io;

import java.io.*;

public class CopyTextFileBuffered {

    public static void main(String[] args) {
        int count = 0;
        try {
            FileReader in = new FileReader("filesource.txt");
            BufferedReader br = new BufferedReader(in);
            FileWriter out = new FileWriter("filesink2.txt");
            BufferedWriter bw = new BufferedWriter(out);
            String line;
            while((line=br.readLine())!=null){
                bw.write(line);
                bw.newLine();
            }
            br.close();
            bw.flush();
            bw.close();
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
        System.out.println("Copied " + count + " characters");
    }
}
